/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainJFrame.java
 *
 * Created on 2011.04.20., 19:13:45
 */
package view;

import controller.Controller;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/**
 *
 * @author Kéki
 */
public class MainJFrame extends javax.swing.JFrame {

    Controller controller;
    /** Creates new form MainJFrame */
    public MainJFrame(Controller con) {
        controller = con;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        mehetButton = new javax.swing.JButton();
        álljButton = new javax.swing.JButton();
        léptetButton = new javax.swing.JButton();
        resetButton = new javax.swing.JButton();
        vaszonJPanel1 = new view.vaszonJPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        loadButton = new javax.swing.JMenuItem();
        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Brute Force 2.0");

        jToolBar1.setRollover(true);

        mehetButton.setText("Mehet");
        mehetButton.setFocusable(false);
        mehetButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        mehetButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        mehetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mehetButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(mehetButton);

        álljButton.setText("Állj");
        álljButton.setFocusable(false);
        álljButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        álljButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(álljButton);

        léptetButton.setText("Léptet");
        léptetButton.setFocusable(false);
        léptetButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        léptetButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        léptetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stepButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(léptetButton);

        resetButton.setText("Reset");
        resetButton.setFocusable(false);
        resetButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        resetButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(resetButton);

        javax.swing.GroupLayout vaszonJPanel1Layout = new javax.swing.GroupLayout(vaszonJPanel1);
        vaszonJPanel1.setLayout(vaszonJPanel1Layout);
        vaszonJPanel1Layout.setHorizontalGroup(
            vaszonJPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 979, Short.MAX_VALUE)
        );
        vaszonJPanel1Layout.setVerticalGroup(
            vaszonJPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 573, Short.MAX_VALUE)
        );

        fileMenu.setText("Fájl");

        loadButton.setText("Betöltés");
        loadButton.setToolTipText("Új hálózat betöltése");
        loadButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        loadButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loadButtonActionPerformed(evt);
            }
        });
        fileMenu.add(loadButton);

        jCheckBoxMenuItem1.setText("Naplózás");
        jCheckBoxMenuItem1.setToolTipText("Kimenet fájlba naplózása");
        fileMenu.add(jCheckBoxMenuItem1);

        jMenuItem1.setText("Kilépés");
        jMenuItem1.setToolTipText("Kilépés a programból");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kilépésButtonActionPerformed(evt);
            }
        });
        fileMenu.add(jMenuItem1);

        jMenuBar1.add(fileMenu);

        helpMenu.setText("Súgó");

        jMenuItem3.setText("Névjegy");
        helpMenu.add(jMenuItem3);

        jMenuBar1.add(helpMenu);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 979, Short.MAX_VALUE)
            .addComponent(vaszonJPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(vaszonJPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void mehetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mehetButtonActionPerformed
        // TODO add your handling code here:
        MyNotSupportedEvent();
    }//GEN-LAST:event_mehetButtonActionPerformed

    private void loadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loadButtonActionPerformed
        // TODO add your handling code here:
        JFileChooser fc = new JFileChooser();
        int showOpenDialog = fc.showOpenDialog(this);
        controller.loadXML(fc.getSelectedFile());
    }//GEN-LAST:event_loadButtonActionPerformed

    private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetButtonActionPerformed
        // TODO add your handling code here:
        controller.reset();
    }//GEN-LAST:event_resetButtonActionPerformed

    private void stepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stepButtonActionPerformed
        // TODO add your handling code here:
        controller.step();
    }//GEN-LAST:event_stepButtonActionPerformed

    private void kilépésButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kilépésButtonActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_kilépésButtonActionPerformed

    //Csak átmenetileg létezik.
    private void MyNotSupportedEvent() {
        JOptionPane.showMessageDialog(null,
                "A grafukus felület jelenlegi verziójából\n ez a funkció még nem érhető el.",
                "Not Supported",
                JOptionPane.ERROR_MESSAGE);
    }

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new MainJFrame().setVisible(true);
//            }
//        });
//    //Azt hiszem ez a megoldás Balázs kívánságára:) Majd ha eljutun odáig, hogy ezzel szöszöljünk kipróbáljuk.
//    //        try {
//    //            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
//    //        } catch (Exception evt) {
//    //        }
//
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu fileMenu;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JMenuItem loadButton;
    private javax.swing.JButton léptetButton;
    private javax.swing.JButton mehetButton;
    private javax.swing.JButton resetButton;
    private view.vaszonJPanel vaszonJPanel1;
    private javax.swing.JButton álljButton;
    // End of variables declaration//GEN-END:variables
}
